package com.skyline.jfs.base.dao.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;

import com.skyline.jfs.base.dao.AdminBasicDao;
import com.skyline.jfs.base.mapper.AdministratorMapper;
import com.skyline.jfs.base.model.Administrator;
import com.skyline.jfs.common.config.Config;

@Component("adminBasicDao")
public class AdminBasicDaoImpl implements AdminBasicDao {

	@Autowired
	private JdbcTemplate jdbcTemplate;

	@Override
	public Administrator find(Long jobNum, String password) {
		String sql = Config.getSql("AdminDao.find");
		Administrator a = jdbcTemplate.queryForObject(sql,
				AdministratorMapper.getMapper(), jobNum, password);
		return a;
	}

	@Override
	public List<Administrator> findAll() {
		String sql = Config.getSql("AdminDao.findAll");
		List<Administrator> as = jdbcTemplate.query(sql,
				AdministratorMapper.getMapper());
		return as;
	}

	@Override
	public Administrator findById(Integer id) {
		String sql = Config.getSql("AdminDao.findById");
		Administrator a = jdbcTemplate.queryForObject(sql, AdministratorMapper.getMapper(), id);
		return a;
	}
	
	public Administrator findByJobNum(Long jobNum){
		String sql = Config.getSql("AdminDao.findByJobNum");
		Administrator a = jdbcTemplate.queryForObject(sql, AdministratorMapper.getMapper(), jobNum);
		return a;
	}

}
